<?php

/**
 * @package Symfony
 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 *
 * @copyright Copyright (C) Tomasz Ignatiuk <tomek.ignatiuk [at] gmail.com>
 * @copyright Copyright (C) Yevgeniy A. Viktorov
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
 
//for example:
//'/home/users/yourhostinguser/public_html/lib/symfony/autoload/sfCoreAutoload.class.php';
require_once '/lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="author" content="Tomasz Ignatiuk, Yevgeniy A. Viktorov" />
<style type="text/css">
body {
	 background-color: black;
	 color: #bbb;
}
.error {
  background-color: red;
  color: white;
  margin: 20px 10px;
  padding: 30px;
  width: 400px;
}
input[type=text] {
  border-style: none;
  background-color: black;
	color: #bbb;
}
input[type=submit] {
  border-style: none;
  background-color: black;
  color: #bbb;
}
</style>
	<title>Symfony CLI without shell access</title>
</head>

<body onload="document.cli.command.focus();">
<?php
if(isset($_POST['command']))
{
  chdir('../');
  $fs = new sfFilesystem();
  try {  
    $res = $fs->execute('php symfony ' . $_POST['command']);
    if(strlen($res[1]) > 0)
      echo $res[1];
    else
      echo preg_replace('/>>*/', '<br />>>',$res[0]);
  } catch (Exception $e) {
      echo '<div class="error">';
      echo 'Error: ',  $e->getMessage(), "\n";
      echo '</div>';
  }
}
?>
<form action="sf_cli.php" method="post" name="cli">
<label for="command">~$ php symfony </label><input type="text" name="command" id="command"/>
<input type="submit" value="Run!" />
</form>
</body>
</html>